import { axiosJson } from "../assets/js/axiosJson";
import store from "../store/index";
// 用户登录信息
export async function memberIdToLogin() {
  const data = {
    member_id: localStorage.memberId,
    is_admin_login: sessionStorage.is_admin_login
  };
  const url = "/security/v1/common/supplierLogin";
  await axiosJson(url, data).then(ret => {
    localStorage.memberId = ret.data.member_id;
    // 新member_id
    sessionStorage.member_id = ret.data.member_id;
    localStorage.LoginUserPhone = ret.data.member_phone;
    sessionStorage.new_token = ret.data.token;
    sessionStorage.company_type = ret.data.company_type;
    if (ret) {
      store.commit("SET_USER_INFO", ret.data);
      store.commit("IS_SIGNIN", true);
    }
  });
}

// 公司配置信息
export async function getConfigureInfo() {
  const data = {
    member_id: localStorage.memberId
  };
  const url = "/security/v1/common/searchConfigureInfo";
  await axiosJson(url, data).then(ret => {
    if (ret) {
      store.commit("SET_CONFIGURE_INFO", ret.data);
    }
  });
}
